package com.entites;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NamedStoredProcedureQueries;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureParameter;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "EventComment")
@XmlRootElement
@NamedQueries(
        {
            @NamedQuery(name = "EventComment.findAll", query = "SELECT e FROM EventComment e"),
            @NamedQuery(name = "EventComment.findById", query = "SELECT e FROM EventComment e WHERE e.id = :id"),
            @NamedQuery(name = "EventComment.findByComment", query = "SELECT e FROM EventComment e WHERE e.comment = :comment"),
            @NamedQuery(name = "EventComment.findByCommented", query = "SELECT e FROM EventComment e WHERE e.commented = :commented"),
            @NamedQuery(name = "EventComment.countCommentByEventId", query = "SELECT COUNT(e.eventId) FROM EventComment e WHERE e.eventId = :EventId"),})

@NamedStoredProcedureQueries(
        {
            @NamedStoredProcedureQuery(name = "EventComment.getEventCommentPaging", procedureName = "sp_getEventCommentPaging",
                    parameters
                    = {
                        @StoredProcedureParameter(name = "beginRow", mode = ParameterMode.IN, type = Integer.class),
                        @StoredProcedureParameter(name = "endRow", mode = ParameterMode.IN, type = Integer.class),
                        @StoredProcedureParameter(name = "eventId", mode = ParameterMode.IN, type = Integer.class)
                    }),
            @NamedStoredProcedureQuery(name = "EventComment.getCountCommentByEventId", procedureName = "sp_getCountCommentByEventId", parameters
                    = {
                @StoredProcedureParameter(name = "eventId", mode = ParameterMode.IN, type = Integer.class)
            }),
            @NamedStoredProcedureQuery(name = "EventComment.getEventCommentByUser", procedureName = "sp_GetEventCommentByUser",
                    parameters
                    = {
                        @StoredProcedureParameter(name = "beginRow", mode = ParameterMode.IN, type = Integer.class),
                        @StoredProcedureParameter(name = "endRow", mode = ParameterMode.IN, type = Integer.class),
                        @StoredProcedureParameter(name = "Username", mode = ParameterMode.IN, type = String.class)
                    }),
             @NamedStoredProcedureQuery(name = "EventComment.PostComment", procedureName = "sp_PostComment",
                    parameters
                    = {
                        @StoredProcedureParameter(name = "eventId", mode = ParameterMode.IN, type = Integer.class),
                        @StoredProcedureParameter(name = "username", mode = ParameterMode.IN, type = String.class),
                        @StoredProcedureParameter(name = "comment", mode = ParameterMode.IN, type = String.class)
                    })
        })
public class EventComment implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "Id")
    private Integer id;
    @Size(max = 1073741823)
    @Column(name = "Comment")
    private String comment;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Commented")
    @Temporal(TemporalType.TIMESTAMP)
    private Date commented;
    @JoinColumn(name = "Username", referencedColumnName = "Username")
    @ManyToOne(optional = false)
    private Employee username;
    @JoinColumn(name = "EventId", referencedColumnName = "EventId")
    @ManyToOne(optional = false)
    private EventLibrary eventId;

    private int evId;
   
    private String usn;
    private String avartar;
    
    public EventComment() {
    }

    public EventComment(Integer id) {
        this.id = id;
    }

    public EventComment(Integer id, Date commented) {
        this.id = id;
        this.commented = commented;
    }

    public EventComment(String comment, Date commented) {
        this.comment = comment;
        this.commented = commented;

    }

    public EventComment(String comment, Date commented, EventLibrary eventId) {
        this.comment = comment;
        this.commented = commented;
        this.eventId = eventId;
    }

    public EventComment(EventLibrary eventId, Employee username, String comment, Date commented) {
        this.eventId = eventId;
        this.username = username;
        this.comment = comment;
        this.commented = commented;
    }
     public EventComment(int evId, String usn, String comment) {
        this.evId = evId;
        this.usn = usn;
        this.comment = comment;
       
    }

    public EventComment(Integer id, EventLibrary eventId, Employee username, String comment, Date commented,String avatar) {
        this.id = id;
        this.eventId = eventId;
        this.username = username;
        this.comment = comment;
        this.commented = commented;
        this.avartar=avatar;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Date getCommented() {
        return commented;
    }

    public void setCommented(Date commented) {
        this.commented = commented;
    }

    public Employee getUsername() {
        return username;
    }

    public void setUsername(Employee username) {
        this.username = username;
    }

    public EventLibrary getEventId() {
        return eventId;
    }

    public void setEventId(EventLibrary eventId) {
        this.eventId = eventId;
    }

    public int getEvId() {
        return evId;
    }

    public void setEvId(int evId) {
        this.evId = evId;
    }

    public String getUsn() {
        return usn;
    }

    public void setUsn(String usn) {
        this.usn = usn;
    }

    public String getAvartar() {
        return avartar;
    }

    public void setAvartar(String avartar) {
        this.avartar = avartar;
    }

    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EventComment)) {
            return false;
        }
        EventComment other = (EventComment) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entites.EventComment[ id=" + id + " ]";
    }

}
